<template>
  <div>
    <slot name="header"></slot>
    <div>
      <swiper ref="mySwiper" :options="swiperOptions">
        <swiper-slide class="picClass" v-for="(item, idx) in carousePicData" :key="idx">
          <img :src="item.imgUrl" alt="" @click="jump(item,idx)">
          <div class="pageShow">
            <span v-text="item.id" class="thisPage"></span>
            <span>/</span>
            <span class="allPage">{{carousePicData.length}}</span>
          </div>
          <div>{{imgText}}</div>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
      <slot name="footer"></slot>
    </div>
  </div>
</template>

<script>
import { Swiper, SwiperSlide, directive } from "vue-awesome-swiper";

// import style (>= Swiper 6.x)
import "swiper/swiper-bundle.css";

export default {
  name: "swiper1",
  props: {
    carousePicData:{
      type:Array,
      required:true
    },
    imgText:{
      type:String
    }
  },
  data() {
    return {
      swiperOptions: {
        pagination: {
          el: ".swiper-pagination",
        },
      },
    };
  },
  components: {
    Swiper,
    SwiperSlide,
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.$swiper;
    },
  },
  directives: {
    swiper: directive,
  },
  mounted() {
    console.log("Current Swiper instance object", this.swiper);
    this.swiper.slideTo(0, 1000, false);
  },
  methods: {
    jump(data,index) {
      this.$emit('jump',{data:data,index:index})
    },
  }
};
</script>

<style>
.picClass {
  width: 100%;
}
.picClass img {
  width: 100%;
  height: 375px;
  display: block;
}
.pageShow {
  background: #193639;
  position: absolute;
  bottom: .1rem;
  width: .5rem;
  height: .3rem;
  right: .12rem;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-radius: 20px;
  opacity: 0.7;
}
.pageShow>span {
  color: #fff;
  font-size: 10px;
}
</style>
